// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Token} from "./Token.sol";

contract FakeLending {
    using SafeERC20 for IERC20;

    // token -> user -> deposit
    mapping(address => mapping(address => uint)) deposits;
    uint256 public profit;

    constructor(uint256 newProfit) {
        profit = newProfit;
    }

    function deposit(address token, uint256 amount) external {
        deposits[token][msg.sender] += amount;
        IERC20(token).safeTransferFrom(msg.sender, address(this), amount);
    }

    function withdraw(address token, uint256 amount) external {
        uint256 depositAmount = deposits[token][msg.sender];
        require(amount <= depositAmount, "FakeLending: withdraw: amount is higher than deposit");

        deposits[token][msg.sender] -= amount;
        Token(token).mint(profit);
        IERC20(token).transfer(msg.sender, amount + profit);
    }
}
